<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class CommonLibraries
{
    public $CI;
    function __construct()
    {
        $this->CI=&get_instance();
    }
    public function GetCrumbs($mid)
    {

        $this->CI->load->Model('Menu_model');
        $mpath= $this->CI->Menu_model->Get_MenuById($mid)->mpath;
        $mids=explode(',',$mpath);
        $crumbsArray=array();
        $i=0;
        foreach($mids as $miditem)
        {
            $_menuModel= $this->CI->Menu_model->Get_MenuById($miditem);
            $crumbs=new Crumbs();
            if($_menuModel->mchild==1){
                $menuModel= $this->CI->Menu_model->Get_First_Child($miditem);
                $crumbs->title=$_menuModel->mtitle;
                $crumbs->url=site_url('admin/'.$menuModel->mctrl.'/'.$menuModel->mact.'/'.$menuModel->mid);
                $crumbsArray[$i]=$crumbs;
            }
            else{
                $crumbs->title=$_menuModel->mtitle;
                $crumbs->url=site_url('admin/'.$_menuModel->mctrl.'/'.$_menuModel->mact.'/'.$_menuModel->mid);
                $crumbsArray[$i]=$crumbs;
            }
            $i++;
        }
        return $crumbsArray;
    }

    public function GetLastMenu($mid)
    {
        $menuModel=$this->CI->Menu_model->Get_MenuById($mid);
        if($menuModel->mchild==1){

        }
    }
}

class Crumbs
{
    public $title;
    public $url;
}
?>
